package com.example.demo.service.impl;

import com.example.demo.mapper.GoodsMapper;
import com.example.demo.mapper.OrderDetailMapper;
import com.example.demo.mapper.OrderMapper;
import com.example.demo.mapper.UserMapper;
import com.example.demo.pojo.vo.BusinessDataVO;
import com.example.demo.service.WorkSpaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WorkSpaceServiceImpl implements WorkSpaceService {

    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private GoodsMapper goodsMapper;
    @Autowired
    private OrderDetailMapper orderDetailMapper;

    @Override
    public BusinessDataVO businessData() {
       Double totalSales=orderMapper.getTotalSales();
       Integer totalPaid=orderMapper.getTotalPaid();
       Integer totalUser=userMapper.getAll();
       Integer totalGoods=goodsMapper.getAll();

       Integer dayOrders=orderMapper.getDayOrders();
       Integer dayValidOrders=orderMapper.getDayValidOrders();
       Double daySales=orderMapper.getDaySales();

       Integer monthOrders=orderMapper.getMonthOrders();
       Integer monthValidOrders=orderMapper.getMonthValidOrders();
       Double monthSales=orderMapper.getMonthSales();

        Double snacks=orderDetailMapper.getByCategory("零食");
        Double goodStuff=orderDetailMapper.getByCategory("好物");
        Double householdGoods=orderDetailMapper.getByCategory("生活用品");
        Double clothing=orderDetailMapper.getByCategory("衣物");
        Double drugs=orderDetailMapper.getByCategory("药品");
        Double sportsProducts=orderDetailMapper.getByCategory("运动产品");

       Integer user1=userMapper.getAge10();
       Integer user2=userMapper.getAge18();
       Integer user3=userMapper.getAge45();

       BusinessDataVO businessDataVO=new BusinessDataVO();
       businessDataVO.setTotalSales(totalSales);
       businessDataVO.setTotalPaid(totalPaid);
       businessDataVO.setTotalUser(totalUser);
       businessDataVO.setTotalGoods(totalGoods);

       businessDataVO.setDayOrders(dayOrders);
       businessDataVO.setValidDayOrders(dayValidOrders);
       businessDataVO.setDaySales(daySales);

       businessDataVO.setMonthOrders(monthOrders);
       businessDataVO.setValidMonthOrders(monthValidOrders);
       businessDataVO.setMonthSales(monthSales);

       businessDataVO.setSnacks(snacks);
       businessDataVO.setGoodStuff(goodStuff);
       businessDataVO.setHouseholdGoods(householdGoods);
       businessDataVO.setClothing(clothing);
       businessDataVO.setDrugs(drugs);
       businessDataVO.setSportsProducts(sportsProducts);

       businessDataVO.setUser1(user1);
       businessDataVO.setUser2(user2);
       businessDataVO.setUser3(user3);
       return businessDataVO;
    }
}
